<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义局部指令</title>
</head>
<body>
<div id="app">
    <ul>
        <li v-for="(item, key) in arr" v-my-click="item">{{ item }}</li>
    </ul>
</div>

<script !src="" type="module">
    import {createApp, reactive} from "../../../../js/vue.esm-browser.js";

    let app = createApp({
        setup() {
            let arr = reactive([1, 2, 3, 4, 5, 6, 7, 8, 9])
            return {
                arr
            }
        },

        directives: {
            "my-click":{
                mounted(el, binding){
                    console.log(el);

                    el.onclick = function (){
                        console.log("点击了列表项" + binding.value);
                    }
                }
            }
        }
    })
    app.mount("#app")
</script>
</body>
</html>